﻿using System.Threading.Tasks;
using GameSdk.MsgHelper;
using HPSocket;
using Quartz;

namespace PinusClientDemo.AllJobs
{
    [DisallowConcurrentExecution]
    public class SendHeartBeatJob : IJob
    {
        public Task Execute(IJobExecutionContext context)
        {
            var client = context.JobDetail.JobDataMap.Get("ITcpPullClient") as ITcpPullClient;
            if (client is not { IsConnected: true })
                return Task.CompletedTask;

            var data = BasicMsgHelper.GetHeartBeatMsg();
            client.Send(data, data.Length);

            return Task.CompletedTask;
        }
    }
}